//
//  YJDView.m
//  YJDSDK
//
//  Created by skyline on 2018/7/25.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "YJDView.h"
CGFloat const TITLE_HEIGHT = 30;
CGFloat const LINE_HEIGHT = 0.8;
CGFloat const SELECTSERBTN_HEIGHT = 15;
CGFloat const BACKBUTTON_HEIGHT = TITLE_HEIGHT;
@interface YJDView()
@property (nonatomic, strong) YJDImageView *imageView;
@property (nonatomic, strong) UIView *line;
@end
@implementation YJDView
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        self.layer.masksToBounds = YES;
        self.bounds = CGRectMake(0, 0, SCREEN_MIN_LENGTH - 2 * GAP,  TEXTFILDHEIGHT * 5 + GAP * 3);
        self.imageView.hidden = ([YJDHelper shareHelp].style == YJDPlatformStyleImage)?NO:YES;
        self.line.hidden = ([YJDHelper shareHelp].style == YJDPlatformStyleImage)?YES:NO;
        self.backBtn.content = ([YJDHelper shareHelp].style == YJDPlatformStyleImage)?@"yjd_返回_Btn":@"back";
        self.backgroundColor = ([YJDHelper shareHelp].style == YJDPlatformStyleImage)?[UIColor clearColor]:RGBA(230, 230, 230, 0.7);
        self.layer.cornerRadius = ([YJDHelper shareHelp].style == YJDPlatformStyleImage)?0.0:5.0;
    }
    return self;
}

- (YJDButton *)backBtn
{
    if (!_backBtn)
    {
        _backBtn = [[YJDButton alloc] init];
        _backBtn.height = BACKBUTTON_HEIGHT;
        _backBtn.style = YJDButtonTitleStyleCameo;
        [_backBtn addTarget:self action:@selector(yjd_actionForBackButton) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_backBtn];
        [_backBtn mas_makeConstraints:^(SK_MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(0);
            if ([YJDHelper shareHelp].style == YJDPlatformStyleImage)
                make.top.equalTo(self).with.offset(GAP);
            else
                make.top.equalTo(self).with.offset(GAP / 2.0);
        }];
    }
    return _backBtn;
}

- (YJDImageView *)imageView
{
    if (!_imageView)
    {
        _imageView = [[YJDImageView alloc] init];
        _imageView.imageName = @"yjd_背景";
        [self addSubview:_imageView];
        [_imageView mas_makeConstraints:^(SK_MASConstraintMaker *make) {
            make.edges.mas_offset(UIEdgeInsetsZero);
        }];
    }
    return _imageView;
}

- (UIView *)line
{
    if (!_line)
    {
        _line = [[UIView alloc] init];
        _line.backgroundColor = RGBA(208, 208, 210, 1.0);
        [self addSubview:_line];
        [_line mas_makeConstraints:^(SK_MASConstraintMaker *make) {
            make.top.equalTo(self).with.offset(TITLE_HEIGHT + GAP);
            make.left.equalTo(self);
            make.right.equalTo(self);
            make.height.mas_equalTo(LINE_HEIGHT);
        }];
    }
    return _line;
}


/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
